﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>驰骋工作流</title>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");

            InitPage();

            $("#Msg").html("");
        });
        //初始化数据.
        function InitPage() {

            var nodeID = GetQueryString("FK_Node");
            var fk_flow = GetQueryString("FK_Flow");

            //所有的nodes.
            var nds = new Entities("BP.WF.Nodes");
            nds.Retrieve("FK_Flow", fk_flow);

            //可以退回的nodes.
            var rnds = new Entities("BP.WF.Template.NodeReturns");
            rnds.Retrieve("FK_Node", nodeID);

            var node = new Entity("BP.WF.Node", nodeID);

            $("#titl").text(node.Name);

            var rndsArr = [];
            $.each(rnds, function (i, obj) {
                rndsArr.push(obj.ReturnTo);
            });

            for (var i = 0; i < nds.length; i++) {
                nd = nds[i];

                if (nd.NodeID == GetQueryString("FK_Node"))
                    continue;

                var newRow = "";
                newRow = "<tr style='width:100%'><td class=Idx style='width:10%'>" + i + "</td>";
                newRow += "<td style='width:20%'>第" + nd.Step + " 步</td>";
                newRow += "<td style='width:20%'>" + nd.NodeID + "</td>";

                if ($.inArray(nd.NodeID, rndsArr) > -1) {
                    newRow += "<td style='width:50%'>" + "<input id='CB_" + nd.NodeID + "' name='CB_" + nd.NodeID + "' type='checkbox' value='" + nd.Name + "' checked='checked' /><label for='CB_" + nd.NodeID + "' >" + nd.Name + "</label></td>";
                } else {
                    newRow += "<td style='width:50%'>" + "<input id='CB_" + nd.NodeID + "' name='CB_" + nd.NodeID + "' type='checkbox' value='" + nd.Name + "' /><label for='CB_" + nd.NodeID + "' >" + nd.Name + "</label></td>";
                }
                newRow += "</tr>";
                $("#table1 tr:last").after(newRow);
            }
            $("#table1 tr:last").after(newBtn);
            return;
        }

        //  提交
        function Btn_Save_Click() {

            var nodeID = GetQueryString("FK_Node");
            var flowNo = GetQueryString("FK_Flow");

            var nodeReturn = new Entity("BP.WF.Template.NodeReturn");
            nodeReturn.Delete("FK_Node", nodeID); //删除已经存在的数据.

            var nds = new Entities("BP.WF.Nodes");
            nds.Retrieve("FK_Flow", flowNo);

            for (var i = 0; i < nds.length; i++) {
                var node = nds[i];

                var checked = $("#CB_" + node.NodeID).prop("checked");

                if (checked == false || checked == undefined)
                    continue;

                nodeReturn.FK_Node = GetQueryString("FK_Node");
                nodeReturn.ReturnTo = node.NodeID;
                nodeReturn.Insert();
            }

            Reload();
            return;
        }
         
    </script>
</head>
<body>
    <form id="cc">
        <div style="right:30px; position:absolute; z-index:100;top:-3px ">
            <input type='button' value='保存' class='Btn' onclick='Btn_Save_Click()' />
        </div>
        <table width='100%' id="table1">
            <caption><img style="margin-bottom:8px;" align="middle" src='../../Img/Event.png' />为'<span id="titl"></span>', 设置退回的节点</caption>
            <tr>
            </tr>
        </table>
        <fieldset>
            <legend>&nbsp;特别说明:&nbsp;</legend>
            <ul>
                <li>只有节点属性的退回规则被设置成退回制订的节点，此功能才有效。 </li>
                <li>设置退回的节点如果是当前节点下一步骤的节点，设置无意义，系统不做检查，退回时才做检查。</li>
            </ul>
        </fieldset>
    </form>
</body>
</html>
